﻿namespace LogManager.Gui.UI.Extensions
{
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Media;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class ImageButton : Button
    {
        #region Fields

        // Dependency property backing variables
        public static readonly DependencyProperty ImageProperty;
        public static readonly DependencyProperty TextProperty;

        #endregion

        #region Constructor

        /// <summary>
        /// Default constructor.
        /// </summary>
        static ImageButton()
        {
            // Initialize as lookless control
            DefaultStyleKeyProperty.OverrideMetadata(typeof(ImageButton),
               new FrameworkPropertyMetadata(typeof(ImageButton)));

            // Initialize dependency properties
            ImageProperty = DependencyProperty.Register("Image",
               typeof(ImageSource), typeof(ImageButton), new UIPropertyMetadata(null));
            TextProperty = DependencyProperty.Register("Text", typeof(string),
               typeof(ImageButton), new UIPropertyMetadata(null));
        }

        #endregion

        #region Custom Control Properties

        /// <summary>
        /// The image displayed by the button.
        /// </summary>
        /// <remarks>The image is specified in XAML as an absolute or relative path.
        /// </remarks>
        public ImageSource Image
        {
            get { return (ImageSource)GetValue(ImageProperty); }
            set { SetValue(ImageProperty, value); }
        }

        /// <summary>
        /// The text displayed by the button.
        /// </summary>
        public string Text
        {
            get { return (string)GetValue(TextProperty); }
            set { SetValue(TextProperty, value); }
        }

        #endregion
    }
}
